
package Mobil;

import Mobil.Mobil;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Astri
 */
public class MobilTabelModel extends AbstractTableModel {
       private List<Mobil> mobil = new ArrayList<Mobil>();

public MobilTabelModel(List<Mobil> mobil){
    this.mobil = mobil;
}       
    public int getRowCount() {
        return mobil.size();
    }

    public int getColumnCount() {
        return 6;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
       Mobil mb = mobil.get(rowIndex);
       switch(columnIndex){
           case 0:            
               return mb.getKode_Mobil();
           case 1 :
               return mb.getTipe_Mobil();
           case 2 :            
               return mb.getNomor_Polisi();
           case 3 :
               return mb.getWarna();
           case 4 :            
               return mb.getStatus_Mobil();
           case 5 :            
               return mb.getHarga_Sewa();
                    
           default :
               return "";
       }
    }
    public String getColumnName (int column){
        switch(column){
            case 0 : 
                return "Kode Mobil";
            case 1 : 
                return "Tipe Mobil";
            case 2 : 
                return "Nomor Polisi";
            case 3 : 
                return "Warna";
            case 4 : 
                return "Status Mobil";
            case 5 : 
                return "Harga Sewa";
            
             default:
                 return "";
        }
    }

}
